

package cn.shengchao.examstar.pay.utils.config;

import com.github.binarywang.wxpay.config.WxPayConfig;
import com.github.binarywang.wxpay.service.WxPayService;
import com.github.binarywang.wxpay.service.impl.WxPayServiceImpl;
import lombok.Getter;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * 微信公众号支付相关配置
 * <p>
 * Created by bjliumingbo on 2017/5/12.
 */
@Configuration
public class WxXcxPayConfig {

    @Value("${notifyUrl}")
    @Getter
    private String notifyUrl;

    private String appId = "wxb939871218e622d0";

    private String mchId = "1714421938";
    private String mchKey = "wsCsqmA5sBc8KuGMU1WX46TcMMtjF6e1";

    private String keyPath = "/usr/soft/tomcat_backend/appandnweb.p12";

    @Bean(name = "WxXcxPay")
    public WxPayConfig payConfig() {
        WxPayConfig payConfig = new WxPayConfig();
        payConfig.setAppId(this.appId);
        payConfig.setMchId(this.mchId);
        payConfig.setMchKey(this.mchKey);
        payConfig.setKeyPath(this.keyPath);
        return payConfig;
    }

    @Bean(name = "WxXcxPayService")
    public WxPayService payService() {
        WxPayService payService = new WxPayServiceImpl();
        payService.setConfig(payConfig());
        return payService;
    }

}
